﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Tradex;
using Tradex.Trading;

namespace Tradex.Connectivity.ConnectorModel {
    
    /// <summary>
    /// This interface encapsulates all functionality regarding the management of trading accounts
    /// that are available from / on a connection.
    /// 
    /// This includes functionaltiy to list accounts as well as to manage orders and positions on
    /// those accounts.
    /// </summary>
    public interface ITradingConnector {

        /// <summary>
        /// This registers the IMarketConnector callback interface with the connector.
        /// </summary>
        /// <param name="callback"></param>
        void SetCallback(
            ITradingConnectorCallback callback
        );

        /// <summary>
        /// Triggers the report of all accounts available on the connector. They will come as
        /// AccountsUpdate callback
        /// </summary>
        void GetAccounts();

        /// <summary>
        /// Requests a replay of all the executions on a given account between a specific
        /// start and end date. An empty end time is identical to the current time, an empty
        /// start time to one month before the current time.
        /// </summary>
        /// <param name="account"></param>
        /// <param name="startMoment"></param>
        /// <param name="endMoment"></param>
        void ReplayExecutions(
            //ReplayKey replayId,
            AccountKey account, DateTime startMoment, DateTime endMoment
        );

        /// <summary>
        /// Requests a replay of all orders processed for a specific account between the timestamps
        /// given in start and end. A missing end time is the current time, a missing start time results
        /// on a one month back time.
        /// </summary>
        /// <param name="account"></param>
        /// <param name="startMoment"></param>
        /// <param name="endMoment"></param>
        void ReplayOrders(
            //ReplayKey replayId,
            AccountKey account, DateTime startMoment, DateTime endMoment
        );

        /// <summary>
        /// Gets all orders active on a specific account. This only reports orders that are active
        /// at the moment.
        /// </summary>
        /// <param name="account"></param>
        void GetAccountOrders(AccountKey account);

        /// <summary>
        /// Creates a new order.
        /// </summary>
        /// <param name="accountKey"></param>
        /// <param name="orderKey"></param>
        /// <param name="orderInfo"></param>
        void CreateOrder (
            AccountKey accountKey,
            OrderKey orderKey,
            OrderInfo orderInfo 
        );
        
        /// <summary>
        /// Modifies an active order.
        /// </summary>
        /// <param name="accountKey"></param>
        /// <param name="orderKey"></param>
        /// <param name="orderConnectionKey"></param>
        /// <param name="orderInfo"></param>
        /// <param name="orderModification"></param>
        void ModifyOrder (
            AccountKey accountKey,
            OrderKey orderKey, OrderId orderConnectionKey,
            OrderInfo orderInfo,
            OrderModification orderModification
        );

        /// <summary>
        /// Cancels an active order. Account and connection order key must be set. The tradex internal
        /// order key is also transmitted so that it can be set if missing. It should normally be present
        /// unless the order was entered externally and the cancel is the first change Tradex does.
        /// </summary>
        /// <param name="accountKey"></param>
        /// <param name="orderKey"></param>
        /// <param name="orderConnectionKey"></param>
        void CancelOrder (
            AccountKey accountKey,
            OrderKey orderKey,
            OrderId orderConnectionKey
        );

    }

}
